package com.css.resoft.p2pmonitor.test;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.css.resoft.p2pmonitor.util.ReadConifgUtil;
import com.resoft.bigdata.p2p.job.DailyReportStatisticReducer;
import com.resoft.bigdata.p2p.job.JobListenerDemo;
import com.resoft.bigdata.p2p.record.MonthlyStatistics;

public class getReport {
	
	public static String host = ReadConifgUtil.getInstance().getHost();
	public static int port = ReadConifgUtil.getInstance().getPort();
	
	public static void main(String[] args) throws Exception {
		
		Set<String> dates = new HashSet<String>();
		dates.add("2018-03-11");
		dates.add("2018-03-12");
		
		
		for(String dateString:dates){
			String format = null;
			if(dateString.contains("-")){
				format = "yyyy-MM-dd";
			}else if(dateString.contains("/")){
				format = "yyyy/MM/dd";
			}else{
				format = "yyyyMMdd";
			}
			SimpleDateFormat sdf = new SimpleDateFormat(format);
			
			Date date = sdf.parse(dateString);
		
			
			DailyReportStatisticReducer reducer = new DailyReportStatisticReducer(host, port, date);
			reducer.addListener(new JobListenerDemo(){
				
				@Override
				public void finishStatistic(String beginDate, String endDate,List<MonthlyStatistics> statistics) {
					
					System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-----------------------------------"+statistics.size());
					
					for(MonthlyStatistics sta: statistics){
						String p2pCode = sta.getP2pOrgCode();
						int yearMonth = sta.getYearAndMonth();
						String p2pName = sta.getP2pOrgName();
						String lvsp = sta.getLVSP();
						String dkcje = sta.getDKCJE();
						String rjjdje = sta.getRJJDJE();
						String pjjkqx = sta.getPJJKQX();
						String zjjlr = sta.getZJJLR();
						String jkbs = sta.getJKBS();
						String dhye = sta.getDHYE();
						String tzrs = sta.getTZRS();
						String dkjkrs = sta.getDKJKRS();
						
						System.out.println("p2pCode: "+p2pCode+" yearMonth: "+yearMonth+" p2pName: "+p2pName+" lvsp: "+lvsp+" dkcje: "+dkcje +
								"rjjdje: "+rjjdje+" pjjkqx: "+pjjkqx+" zjjlr: "+zjjlr+" jkbs: "+jkbs+" dhye: "+dhye+" tzrs: "+tzrs +" dkjkrs: "+dkjkrs);
						
					}
				}	
			
			});
		reducer.run();
//		reducer.cal();
		}		
	}
}
